/* jialianMasterMib.c - IDB+ Module source for jialianMasterMib.mi2. */

/* Copyright 2013 Wind River, Inc. */
/*
modification history
--------------------
xxx,22Mar13,idb Created by IDBGEN. Ver 2.28
%%BeginUserCode jialianMasterMib_Modifications
%%EndUserCode   jialianMasterMib_Modifications
*/

/*
DESCRIPTION
This module defines the IDB+ structures and IDB+ Object handler routines to
access the IDB+ objects defined in jialianMasterMib.mi2.

INCLUDE FILES: jialianMasterMib.h
*/

/* Includes */
#include "neos_vx_win.h"
#include "jialianMib_function.h"
#include "idbLib.h"
#include "jialianMasterMib.h"

/* %%BeginUserCode jialianMasterMib_IncludeFiles */
/* %%EndUserCode   jialianMasterMib_IncludeFiles */

/* Defines */
/* %%BeginUserCode jialianMasterMib_Defines */
/* %%EndUserCode   jialianMasterMib_Defines */

/* Globals */
/* %%BeginUserCode jialianMasterMib_Globals */
/* %%EndUserCode   jialianMasterMib_Globals */

/* Locals */
LOCAL char * moduleName = "jialianMasterMib";
/* %%BeginUserCode jialianMasterMib_Locals */
/* %%EndUserCode   jialianMasterMib_Locals */

/* Prototypes */
LOCAL STATUS jialianMasterMibScalarHandler ( idbRequest_t request, idb_t * idb );

/* %%BeginUserCode jialianMasterMib_Prototypes */
/* %%EndUserCode   jialianMasterMib_Prototypes */


/****************************************************************************
* IDB+ Module Object Descriptors
*/
//unsigned long int Myoid[11]={1,3,6,1,4,1,123456,1,101,1,1};
char *Myoid="1.3.6.1.4.1.123456.1.101.1.15";
LOCAL idbObjDesc_t equipId_objDesc[] = {
  { equipId, 1, 4, /* localId=0  1.3.6.1.4.1.123456.1.1.1 */
    { 0, 0 }, IDB_Unsigned32, IDB_READ,
    (IDB_VALID), jialianMasterMibScalarHandler,
    (char *)0, "jialianMasterMib:equipId" },
  { 0 }
};

LOCAL idbObjDesc_t equipType_objDesc[] = {
  { equipType, 2, 4, /* localId=1  1.3.6.1.4.1.123456.1.1.2 */
    { 1, 19 }, IDB_INTEGER, IDB_READ|IDB_SET,
    (IDB_VALID), jialianMasterMibScalarHandler,
    (char *)0, "jialianMasterMib:equipType" },
  { 0 }
};

/*****************************************************************************
* IDB+ Module OID Table
*
* The OID list below (e.g.,{1,3,6,1, ...}) is the OID prefix minus the
* last sub-identifier.  The last sub-identifier is found in the
* object descriptor idbObjDesc_t structure.
*/

LOCAL idbOidTable_t oidTable[] = {
  /*   0: Scalar Object -- equipId */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,1}, 10,   /*lint !e785 */
    0, 1, { 0 },
    equipId_objDesc },

  /*   1: Scalar Object -- equipType */
  { IDB_SNMP_STRUCT, {1,3,6,1,4,1,123456,1,1}, 10,   /*lint !e785 */
    0, 1, { 0 },
    equipType_objDesc },

  { IDB_TERMINATOR }
};

/*****************************************************************************
* IDB+ Module Translate Table
*/

LOCAL idbXlateTable_t xlateTable[] = {
    { &oidTable[  0], &equipId_objDesc[0] },
    { &oidTable[  1], &equipType_objDesc[0] },

    { 0 }
};

/******************************************************************************
* User Local Functions.
*/

/* %%BeginUserCode jialianMasterMib_UserFunctions */
/* %%EndUserCode   jialianMasterMib_UserFunctions */


/****************************************************************************
*
* jialianMasterMibInit - initialize/register jialianMasterMib and objects.
*
* This routine initializes the modules IDB routines.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS jialianMasterMibInit
    (
    void * parm1,
    void * parm2
    )
    {
    STATUS    rc;

    /* %%BeginUserCode jialianMasterMibInit_Prolog */
    /* %%EndUserCode   jialianMasterMibInit_Prolog */

    rc = SNMP_OK;

    /* %%BeginUserCode jialianMasterMibInit_Body */
    /* %%EndUserCode jialianMasterMibInit_Body */

    /* Register the module's information with IDB+ engine */
    rc = idbModuleRegister( moduleName, &xlateTable[0] );

    /* %%BeginUserCode jialianMasterMibInit_Epilog */
    /* %%EndUserCode   jialianMasterMibInit_Epilog */

    return( rc );
    }

/******************************************************************************
*
* jialianMasterMibTerminate - Terminate jialianMasterMib and objects.
*
* This routine de-initializes the IDB module functions.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

STATUS jialianMasterMibTerminate
    (
    void * parm
    )
    {
    STATUS    rc;

    /* %%BeginUserCode jialianMasterMibTerminate_Prolog */
    /* %%EndUserCode   jialianMasterMibTerminate_Prolog */

    rc = SNMP_OK;

    /* De-register the module's information with IDB+ engine */
    idbModuleDeRegister( moduleName );

    /* %%BeginUserCode jialianMasterMibTerminate_Epilog */
    /* %%EndUserCode   jialianMasterMibTerminate_Epilog */

    return( rc );
    }

/******************************************************************************
*
* jialianMasterMibScalarHandler - handles all scalar objects.
*
* This routine handles all scalar objects for this IDB+ Module.
*
* RETURNS: SNMP_OK or SNMP_ERROR
*
* ERRNO: N/A
*/

LOCAL STATUS jialianMasterMibScalarHandler
    (
    idbRequest_t request,
    idb_t * idb
    )
    {
    STATUS    rc;

    /* %%BeginUserCode jialianMasterMibScalarHandler_Prolog */
    /* %%EndUserCode   jialianMasterMibScalarhandler_Prolog */

    rc = SNMP_OK;

    /* Validate the Scalar indexSubIdCount and instance value */
    if ( idbScalarValidate( request, idb ) == SNMP_ERROR )
        return idbErrorRequestMap( request );

    switch( idb->localId )
    {
    default:
        rc = idbErrorNoSuchInstance();
        break;

    /* ================================================================= */
    case equipId:    /* Unsigned32, read-only */
        {
        /* %%BeginUserCode equipId_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:
		
            break;
        }

        /* %%EndUserCode   equipId_Body */
        }
        break;

    /* ================================================================= */
    /*
    * EequipType_m00001_iCombo 1
    * EequipType_m00002_weatherInHouse 2
    * EequipType_m00003_energy 3
    * EequipType_m00004_weatherOutHouse 4
    * EequipType_m00005_security 5
    * EequipType_m00006_splAirCondStatus 6
    * EequipType_m00007_cenAirCond 7
    * EequipType_m00008_fanCoil 8
    * EequipType_m00009_freshAir 9
    * EequipType_m00010_floorHeat 10
    * EequipType_m00011_light 11
    * EequipType_m00012_curtain 12
    * EequipType_m00013_dehumidifier 13
    * EequipType_m00014_humidifiens 14
    * EequipType_m00015_blower 15
    * EequipType_m00016_exhaust 16
    * EequipType_m00017_airCondBox 17
    * EequipType_m00018_remoteSocket 18
    * EequipType_m00019_iComboPower 19
    */
    case equipType:    /* INTEGER, read-only */
        {
        /* %%BeginUserCode equipType_Body */

        switch ( request )
        {
        case IDB_GET_NEXT:
            /* Check to make sure the next object is valid. */
            rc = idbNextScalarIndex(idb);

            /* FALLTHRU */
        case IDB_GET:
			rc = jilian_demo_get (idb->pValueBuf);
            if ( rc == SNMP_OK )
            {
                idb->valueLen = 4;
            }

            break;

        case IDB_VALIDATE:
            break;

        case IDB_SET_NVM:
            break;

        case IDB_COMMIT:

	//		jilian_demo_set(idb->pValueBuf);
		//	Myoid[10]=1;
			rc=jilian_set(Myoid,(idb->pValueBuf));
            break;
        }

        /* %%EndUserCode   equipType_Body */
        }
        break;

    }

    /* %%BeginUserCode jialianMasterMibScalar_Epilog */
    /* %%EndUserCode   jialianMasterMibScalar_Epilog */

    return( rc );
    }

